

package com.hex.ds.code.detection.config.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hex.ds.code.detection.config.model.ConfigPropertyServer;
import com.hex.ds.code.detection.common.annotation.AnonymousAccess;
import org.springframework.http.ResponseEntity;
import com.hex.ds.code.detection.config.service.ConfigPropertyServerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 服务器配置表
 *
 * @author zl
 * @date 2024-02-05 10:06:17
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/configpropertyserver" )
@Api(value = "configpropertyserver", tags = "服务器配置表管理")
public class ConfigPropertyServerController {

    private final  ConfigPropertyServerService configPropertyServerService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param configPropertyServer 服务器配置表
     * WrapperEnhancer.like(configPropertyServer); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @AnonymousAccess
    public ResponseEntity<Object> getConfigPropertyServerPage(Page page, ConfigPropertyServer configPropertyServer) {
        return ResponseEntity.ok(configPropertyServerService.queryList(page,configPropertyServer));
    }

    @ApiOperation(value = "不分页查询", notes = "不分页查询")
    @GetMapping("/nopage" )
    @AnonymousAccess
    public ResponseEntity<Object> getConfigPropertyServerNoPage() {
        return ResponseEntity.ok(configPropertyServerService.findAll());
    }


    /**
     * 通过id查询服务器配置表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @AnonymousAccess
    public ResponseEntity<Object> getById(@PathVariable("id" ) String id) {
        return ResponseEntity.ok(configPropertyServerService.getById(id));
    }

    /**
     * 新增服务器配置表
     * @param configPropertyServer 服务器配置表
     * @return R
     */
    @ApiOperation(value = "新增服务器配置表", notes = "新增服务器配置表")
    @PostMapping
    @AnonymousAccess
    public ResponseEntity<Object> save(@RequestBody ConfigPropertyServer configPropertyServer) {
        return ResponseEntity.ok(configPropertyServerService.save(configPropertyServer));
    }

    /**
     * 修改服务器配置表
     * @param configPropertyServer 服务器配置表
     * @return R
     */
    @ApiOperation(value = "修改服务器配置表", notes = "修改服务器配置表")
    @PutMapping
    @AnonymousAccess
    public ResponseEntity<Object> updateById(@RequestBody ConfigPropertyServer configPropertyServer) {
        return ResponseEntity.ok(configPropertyServerService.updateById(configPropertyServer));
    }

    /**
     * 通过id删除服务器配置表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除服务器配置表", notes = "通过id删除服务器配置表")
    @DeleteMapping("/{id}" )
    @AnonymousAccess
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(configPropertyServerService.removeById(id));
    }

}
